package com.songhq.filterandintercept.config;


import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import com.songhq.filterandintercept.intercepter.StaticdataInterceptor;


@Configuration
public class StaticDataWebAppConfigurer extends WebMvcConfigurerAdapter {
    

	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		//相当于重定向的意思,用于访问静态资源
		registry.addResourceHandler("/staticdata/**").addResourceLocations("file:/home/songhq/staticdata/")
        .setCachePeriod(60);
		super.addResourceHandlers(registry);
	}
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
    	//springBoot会将路径编程/error
	    registry.addInterceptor(new StaticdataInterceptor()).addPathPatterns("/error/**");
        super.addInterceptors(registry);
	}
}